AddCSLuaFile( "cl_init.lua" )
AddCSLuaFile( "shared.lua" )
include( 'shared.lua' )

function ENT:Initialize()
	self.BaseClass.Initialize(self)
	self.damaged = 0
	self.caf.custom.masschangeoverride = true
	self.WireDebugName = self.PrintName
	self.Outputs = Wire_CreateOutputs(self.Entity, { 
	"Blue Ice", 
	"Clear Ice", 
	"Glacial Mass", 
	"White Glaze", 
	"Dark Glitter", 
	"Glare Crust", 
	"Gelidus", 
	"Krystallos",
	"Max Blue Ice",	
	"Max Clear Ice",
	"Max Glacial Mass",
	"Max White Glaze",
	"Max Dark Glitter",
	"Max Glare Crust",
	"Max Gelidus",
	"Max Krystallos"
	}) 	
		

end

function ENT:SpawnFunction( ply, tr )

if ( !tr.Hit ) then return end
	
	local SpawnPos = tr.HitPos + tr.HitNormal * 100
	
	local ent = ents.Create( "mining_laser_base" )
		ent:SetPos( SpawnPos )
		ent:Spawn()
		ent:Activate() 
	return ent
end



function ENT:OnRemove()
	
end

function ENT:Think()
	self.BaseClass.Think(self)
	
	self:UpdateWireOutput()	
	
			
end

function ENT:UpdateWireOutput()
	local ice1 = RD.GetResourceAmount(self, "Blue Ice") 
	local ice2 = RD.GetResourceAmount(self, "Clear Ice") 
	local ice3 = RD.GetResourceAmount(self, "Glacial Mass") 
	local ice4 = RD.GetResourceAmount(self, "White Glaze") 
	local ice5 = RD.GetResourceAmount(self, "Dark Glitter") 
	local ice6 = RD.GetResourceAmount(self, "Glare Crust") 
	local ice7 = RD.GetResourceAmount(self, "Gelidus") 
	local ice8 = RD.GetResourceAmount(self, "Krystallos") 
	
	local maxice1 = RD.GetNetworkCapacity(self, "Blue Ice") 
	local maxice2 = RD.GetNetworkCapacity(self, "Clear Ice") 
	local maxice3 = RD.GetNetworkCapacity(self, "Glacial Mass") 
	local maxice4 = RD.GetNetworkCapacity(self, "White Glaze") 
	local maxice5 = RD.GetNetworkCapacity(self, "Dark Glitter") 
	local maxice6 = RD.GetNetworkCapacity(self, "Glare Crust") 
	local maxice7 = RD.GetNetworkCapacity(self, "Gelidus") 
	local maxice8 = RD.GetNetworkCapacity(self, "Krystallos")
		
	Wire_TriggerOutput(self, "Blue Ice", ice1)
	Wire_TriggerOutput(self, "Clear Ice", ice2)
	Wire_TriggerOutput(self, "Glacial Mass", ice3)
	Wire_TriggerOutput(self, "White Glaze", ice4)
	Wire_TriggerOutput(self, "Dark Glitter", ice5)
	Wire_TriggerOutput(self, "Glare Crus", ice6)
	Wire_TriggerOutput(self, "Gelidus", ice7)
	Wire_TriggerOutput(self, "Krystallos", ice8)
	
	Wire_TriggerOutput(self, "Max Blue Ice", maxice1)
	Wire_TriggerOutput(self, "Max Clear Ice", maxice2)
	Wire_TriggerOutput(self, "Max Glacial Mass", maxice3)
	Wire_TriggerOutput(self, "Max White Glaze", maxice4)
	Wire_TriggerOutput(self, "Max Dark Glitter", maxice5)
	Wire_TriggerOutput(self, "Max Glare Crus", maxice6)
	Wire_TriggerOutput(self, "Max Gelidus", maxice7)
	Wire_TriggerOutput(self, "Max Krystallos", maxice8)
end



